#!/usr/bin/make -f
# -*- makefile -*-
# Sample debian/rules that uses debhelper.
#
# This file was originally written by Joey Hess and Craig Small.
# As a special exception, when this file is copied by dh-make into a
# dh-make output file, you may use that output file without restriction.
# This special exception was added by Craig Small in version 0.37 of dh-make.
#
# Modified to make a template file for a multi-binary package with separated
# build-arch and build-indep targets  by Bill Allombert 2001

# Uncomment this to turn on verbose mode.
#export DH_VERBOSE=1

# This has to be exported to make some magic below work.
export DH_OPTIONS


%:
	dh $@ 

override_dh_clean:
	dh_clean
	xbuild /property:Configuration=Release /target:Clean Duplicati.sln
	find -type d -name bin | xargs rm -rf
	find -type d -name obj | xargs rm -rf
	find -maxdepth 1 -type d -name build | xargs rm -rf

override_dh_auto_build:
	xbuild /property:Configuration=Release Duplicati.sln

override_dh_auto_install:
	mkdir build
	mkdir build/bin
	mkdir build/lib
	mkdir build/lib/duplicati
	mkdir build/lib/duplicati/SQLite
	mkdir build/share
	mkdir build/share/applications
	mkdir build/share/pixmaps
	cp Installer/debian\ help/duplicati-launcher.sh build/bin/duplicati
	cp Installer/debian\ help/duplicati-commandline-launcher.sh build/bin/duplicati-cli
	cp Installer/debian\ help/duplicati-server-launcher.sh build/bin/duplicati-server
	cp Duplicati/GUI/Duplicati.GUI.TrayIcon/bin/Release/*.dll build/lib/duplicati/
	cp Duplicati/GUI/Duplicati.GUI.TrayIcon/bin/Release/*.exe build/lib/duplicati/
	cp Duplicati/GUI/Duplicati.GUI.TrayIcon/bin/Release/*.exe.config build/lib/duplicati/
	cp -r Duplicati/GUI/Duplicati.GUI.TrayIcon/bin/Release/SQLite/pinvoke build/lib/duplicati/SQLite/
	cp Duplicati/GUI/Duplicati.GUI.TrayIcon/bin/Release/default_compressed_extensions.txt build/lib/duplicati/
	cp -r Duplicati/GUI/Duplicati.GUI.TrayIcon/SVGIcons/ build/lib/duplicati/
	cp -r Duplicati/GUI/Duplicati.GUI.TrayIcon/bin/Release/licenses build/lib/duplicati/
	cp -r Duplicati/Server/webroot build/lib/duplicati/
	cp Installer/debian\ help/duplicati.desktop build/share/applications
	cp Installer/debian\ help/duplicati.xpm build/share/pixmaps
	cp Installer/debian\ help/duplicati.png build/share/pixmaps
	bash Installer/debian\ help/install-oem.sh
	rm build/lib/duplicati/AlphaFS.dll
	rm build/lib/duplicati/AlphaVSS.Common.dll
	rm build/lib/duplicati/MonoMac.dll
	chmod 644 build/lib/duplicati/*.dll
	find build/lib/duplicati/webroot/* -type d | xargs chmod 755
	find build/lib/duplicati/webroot/* -type f | xargs chmod 644
	dh_install

#override_dh_auto_install:
#	rm -rf Duplicati/GUI/Duplicati.GUI.TrayIcon/bin/Release/*.mdb
#	rm -rf Duplicati/GUI/Duplicati.GUI.TrayIcon/bin/Release/alphavss
#	mkdir ${DESTDIR}/usr/lib/duplicati/
#	cp -R Duplicati/GUI/Duplicati.GUI.TrayIcon/bin/Release/* ${DESTDIR}/usr/lib/duplicati/
#	cp -R Duplicati/Server/webroot ${DESTDIR}/usr/lib/duplicati/
